﻿using System.Windows;
using System.Windows.Controls;

namespace IssueVision.Common
{
    /// <summary>
    /// Custom content control class with animated screen transition
    /// </summary>
    [TemplateVisualState(Name = "MainPageStateA", GroupName = "MainPageStates"),
    TemplateVisualState(Name = "MainPageStateB", GroupName = "MainPageStates")]
    public class MainPageContentControl : ContentControl
    {
        public MainPageContentControl()
        {
            DefaultStyleKey = typeof(MainPageContentControl);
        }

        #region "Public Methods"
        public object ChangeMainPageContent(object newScreen, bool useTransitions)
        {
            VisualStateManager.GoToState(this, "MainPageStateA", false);
            var previousScreen = Content;
            Content = newScreen;
            VisualStateManager.GoToState(this, "MainPageStateB", useTransitions);

            return previousScreen;
        }
        #endregion "Public Methods"
    }
}
